package com.dldata.devtools30.common;

import java.util.ArrayList;
import java.util.List;

/**
 * 系统支持机构列表
 */
public class EnumOrganization {
    
    public final static List<EnumOrganization> enumOrganizationList=new ArrayList<>();
    public final static EnumOrganization enumOrganization=new EnumOrganization("dldata","雕龙数据");
    public final static EnumOrganization enumOrganizationClone=new EnumOrganization("dldataclone","雕龙数据克隆");
    
    static{
        enumOrganizationList.add(enumOrganization);
        enumOrganizationList.add(enumOrganizationClone);
    }
    
    private String code;
    
    private String name;
    
    public String getCode() {
        return code;
    }
    
    public String getName() {
        return name;
    }
    
    public EnumOrganization(String code, String name){
        this.code=code;
        this.name=name;
    }
    
    public static EnumOrganization getInstanceFromName(String name){
        EnumOrganization[] enumOrganizations = enumOrganizationList.toArray(new EnumOrganization[enumOrganizationList.size()]);
        for (int i = 0; i < enumOrganizations.length; i++) {
            EnumOrganization enumOrganization = enumOrganizations[i];
            if(enumOrganization.name.equals(name)){
                return enumOrganization;
            }
        }
        return null;
    }
    
    public static EnumOrganization getInstanceFromCode(String code){
        EnumOrganization[] enumOrganizations = enumOrganizationList.toArray(new EnumOrganization[enumOrganizationList.size()]);
        for (int i = 0; i < enumOrganizations.length; i++) {
            EnumOrganization enumOrganization = enumOrganizations[i];
            if(enumOrganization.code.equals(code)){
                return enumOrganization;
            }
        }
        return null;
    }
}
